﻿using System;
using System.ServiceProcess;
using System.Threading;
using MedSoft.Library.Logging;
using MedSoft.Library.Utilities;

namespace UrDnd.IrcBot.Service
{
	[Log]
	internal partial class IrcBotService : ServiceBase
	{
		private readonly Thread _thread = new Thread(new IrcBot().Launch);

		public IrcBotService()
		{
			InitializeComponent();
		}

		protected override void OnStart(string[] args)
		{
			Singleton<Logger>.Instance.Info("Starting UrD&D bot");

			_thread.Start(this);
		}

		protected override void OnStop()
		{
			Singleton<Logger>.Instance.Info("Shutdowning UrD&D bot");
			_thread.Abort(true);
			_thread.Join();
		}
	}
}